<#if roles.canInMoney>
<div class="col-md-12 plan-payin">
	<div class="panel panel-primary">
		<div class="panel-heading">
			<h3 class="panel-title">
				<i class="icon-signin icon-large"></i>
				7日内待收款任务
			</h3>
		</div>
		<#if payinPlan??>
		<table class="table table-hover">
			<tr>
				<th class="text-center" width="55">操作</th>
				<th class="text-center" width="70">状态</th>
				<th class="text-center" width="180">收款金额（元）</th>
				<th class="text-center" width="115">收款时间</th>
				<th class="text-center">收款事项</th>
				<th class="text-center" width="100">创建人</th>
				<th class="text-center" width="225">合同编号</th>
				<th class="text-center">合同名称</th>
			</tr>
			<#list payinPlan as p>
			<!--  -->
			<#assign url=((p.contract.mainContract)?string('contract','sub-contract'))!'contract'>
			<tr class="${((p.back)?string('text-deleted',((p.overDate)?string('text-danger',''))))}" style="cursor: pointer;" data-url="${url}" data-cid="${p.contract.id}">
				<td class="text-center"><#if p.back?? && !p.back>
					<div class="btn btn-danger btn-xs payin-by-plan" data-id="${p.contract.id}" data-plan-id="${p.id}">收款</div> </#if>
				</td>
				<td class="text-center cell-for-open">${((p.back)?string('已收回','待收'))}</td>
				<td class="text-center cell-for-open">${p.total?string('currency')}</td>
				<td class="text-center cell-for-open">${(p.backTime?string('yyyy-MM-dd'))!'-'}</td>
				<td class="text-center cell-for-open">${p.reason}</td>
				<td class="text-center cell-for-open">${p.creater.name}</td>
				<td class="text-center cell-for-open">${p.contract.no}</td>
				<td class="text-center cell-for-open">${p.contract.name}</td>
			</tr>
			</#list>
		</table>

		<script type="text/javascript">
			require([ 'suredyModal', 'suredy' ], function(Modal) {
				// 打开合同
				$('.plan-payin').on('click', '.cell-for-open', function() {
					var $this = $(this);
					var tr = $this.parent('tr');
					var url = tr.data('url');
					var cid = tr.data('cid');

					window.open('${request.contextPath}/' + url + '/view/' + cid + '/%23tab-head5', '_blank');
				});

				// 通过收款计划收款
				$('.plan-payin').on('click', '.btn.payin-by-plan', function() {
					var $this = $(this);
					var id = $this.data('id'); // 合同
					var planId = $this.data('plan-id'); // 收款计划

					Modal.showModal({
						showFoot : false,
						icon : 'icon-ok',
						title : '收款确认',
						uri : '${request.contextPath}/contract/payin-money-confirm',
						data : {
							id : id,
							planId : planId
						}
					});

					return false;
				});
			});
		</script>
		<#else>
		<div class="panel-body text-danger">暂无7日内计划！</div>
		</#if>
	</div>
</div>
</#if>
